﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace XoLib.Tools
{
    /// <summary>
    /// Extention
    /// <example> "Form1".InvokeClass Form (); </example>/// 
    /// </summary>
    public static class cInvoke
    {

        /// <summary>
        /// <para>
        /// <param name="sClass">string</param>
        /// </para>
        /// Form test = "Form1".InvokeClass Form (); 
        /// </summary>
        public static T InvokeClass<T>(this string sClass)
        {
            Type type = null;
            if (sClass != null && (type = Type.GetType(sClass)) != null)
                return (T)System.Activator.CreateInstance(type);
            else
                return default(T);
        }

        /// <summary>
        /// <para>
        /// <param name="sClass">string</param>
        /// </para>
        /// Type test = "Form1".GetContainsType(); 
        /// </summary>
        public static Type GetContainsType(this string sClass)
        {
            Type type = null;
            if (sClass != null && (type = Type.GetType(sClass)) != null)
                return type;
            else
                return type;
        }

    }





}
